/*
AlliedBridge Content Management System
Copyright (C) 2006 AlliedBridge

This program is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software Foundation;

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.volume4.utils;

import javax.servlet.http.HttpServlet;

/**
 * @author Schalk
 */

public class ServletUtilities extends HttpServlet {

    public static String filter(String input) {
        StringBuffer filtered = new StringBuffer(input.length());
        char c;
        for (int i = 0; i < input.length(); i++) {
            c = input.charAt(i);
            if (c == '\'') {
                filtered.append("&acute;");
            } else if (c == '"') {
                filtered.append("&quot;");
            } else {
                filtered.append(c);
            }
        }
        return (filtered.toString());
    }

    public static String provinceFilter(String province) {
        StringBuffer provFiltered = new StringBuffer(province.length());

        if (!province.trim().equalsIgnoreCase("")) {
            if (province.equalsIgnoreCase("Limpopo")) {
                provFiltered.append("LP");
            } else if (province.equalsIgnoreCase("North West")) {
                provFiltered.append("NW");
            } else if (province.equalsIgnoreCase("Mpumalanga")) {
                provFiltered.append("MP");
            } else if (province.equalsIgnoreCase("Free State")) {
                provFiltered.append("FS");
            } else if (province.equalsIgnoreCase("Gauteng")) {
                provFiltered.append("GP");
            } else if (province.equalsIgnoreCase("Kwazulu Natal")) {
                provFiltered.append("KZN");
            } else if (province.equalsIgnoreCase("Western Cape")) {
                provFiltered.append("WC");
            } else if (province.equalsIgnoreCase("Nortern Cape")) {
                provFiltered.append("NC");
            } else {
                provFiltered.append("EC");
            }
        }
        return (provFiltered.toString());
    }
}